package java51.homew0614;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class Clent2 {

	public static void main(String[] args) {
		try {
			Socket s = new Socket("192.168.1.98", 8888);
			while (true) {
				InputStream in = s.getInputStream();
				int lens = in.read();
				byte b[] = new byte[lens];
				in.read(b);
				String str = new String(b);
				if (b.equals("所有文件读取完成"))
					break;
				File f = new File("D:\\2233", str);
				FileOutputStream out = new FileOutputStream(f);
				int len = 0;
				while ((len = in.read()) > -1) {
					out.write(len);
				}
				// int lens1 = in.read();
				// byte b1[] = new byte[lens1];
				// in.read(b1);
				// System.out.println(new String(b1));
				in.close();
				out.close();
			}
		} catch (IOException e) {
			e.printStackTrace();
		}

	}
}